package com.hc.dfs.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.hc.dfs.dailog.DelayDialog;
import com.hc.dfs.entities.mobile.FollowDetail;
import com.hc.dfs.handle.DetailPage;
import com.hc.dfs.handle.DetailPageFactory;

/**
 * @author 王洪胜 E-mail:
 * @version 创建时间：2013-2-21 上午11:43:50
 * 
 *          类说明：公文详情类
 * 
 */
public class DocumentDetailsActivity extends BaseActivity {

	public static final Object GET_DOCUMENT_DETAIL_SUCCESS = 1;
	private int docType;
	private int page;
	private Intent intent = getIntent();
	private DetailPageFactory dpf;
	private DetailPage dp;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//捕获list列表中传递过来的页码和公文类型
		intent = getIntent();
		docType = Integer.parseInt(intent.getStringExtra("docType"));
		page = Integer.parseInt(intent.getStringExtra("page"));
		//根据页码和公文类型生成公文详情
		dpf = new DetailPageFactory(this, page, docType);
		dp = dpf.createDetailPage();
		//给页面中的按钮绑定监听器
		dp.back_btn.setOnClickListener(this);
		dp.btn1.setOnClickListener(this);
		dp.btn2.setOnClickListener(this);
		dp.btn3.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		//返回按钮
		if(id==R.id.button1){
			finish();
		}
		//其他操作按钮
		if (page == 0) {
			switch (id) {
			case R.id.btn1:
				System.out.println("切换到签批操作页面");
				startActivity(new Intent(this, SigningOperationActivity.class));
				break;
			case R.id.btn2:
				System.out.println("切换到申请延时对话框");
				new DelayDialog(R.layout.delay_dialog, this);
				break;
			case R.id.btn3:
				System.out.println("查看签批路径");
				startActivity(new Intent(this, SearchActivity.class));
				break;
			default:
				break;
			}
		} else if (page == 1) {
			switch (id) {
			case R.id.btn2:
				System.out.println("跟踪进度");
				startActivity(new Intent(this, FollowDetail.class));
				break;
			case R.id.btn3:
				System.out.println("查看签批路径");
				startActivity(new Intent(this, SearchActivity.class));
				break;
			default:
				break;
			}
		}else if(page==2){
			if(id==R.id.btn3){
				System.out.println("删除公文按钮");
			}
		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		dp.onKeyDown(keyCode, event);
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub

	}

}
